package chat;

import gui.ChatVoxGui;

import java.io.ObjectInputStream;
import java.net.Socket;


public class ClientHandler extends Thread{
	
	public Socket client;
	private String mensagemRecebida;
	private ChatVoxGui chatVoxGui;
	
	public ClientHandler(Socket socket, ChatVoxGui chatVoxGui)
	{
		this.client = socket;
		this.chatVoxGui = chatVoxGui;
	}
	
	public void run()
	{
		try
		{   String msg;
			ObjectInputStream oi = new ObjectInputStream(client.getInputStream());   
			this.mensagemRecebida = (String) oi.readObject();
			msg = "Seu amigo diz: \n" + this.mensagemRecebida + "\n" ;
			this.chatVoxGui.SetTextAreaConversa(msg);
			client.close(); 
		}
		
		catch(Exception e){  
			e.printStackTrace();  
			System.exit(1);  
		}  
	}
}
